﻿@page "/TaskDetail/{WorkFlowName}/{ParentID}"
@using WorkFlow.Data
@using WorkFlow.Data.Model
@inject CommentTool commentTool
@inject List<TaskDetailEntity> taskDetailEntity
@inject DataManager _DataManager
<h3>TaskDetail</h3>
<div>
    <table class="table">
        <thead>
            <tr>
                <th>Sno</th>
                <th style="width: 50%;">WorkFlowName</th>
                <th>Result</th>
                <th>CreateTime</th>
            </tr>
        </thead>
        <tbody>
            @if (taskDetailEntity != null)
            {
                for (var i = 0; i < taskDetailEntity.Count; i++)
                {
                    TaskDetailEntity ruleItem = taskDetailEntity[i];
                    <tr>
                        <td>@(i+1)</td>
                        <td>WorkFlowName</td>
                        <td>@ruleItem.Result</td>
                        <td>@ruleItem.CreateTime</td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>

@code {
    [Parameter]
    public string ParentID { get; set; }
    [Parameter]
    public string WorkFlowName { get; set; }
    protected override void OnParametersSet()
    {
        commentTool.ShowNav = false;
        base.OnParametersSet();
    }
    protected override void OnAfterRender(bool firstRender)
    {
        commentTool.ShowNav = false;
        base.OnAfterRender(firstRender);
        if (firstRender)
            Search();
    }
    private void Search()
    {
        taskDetailEntity = _DataManager.GetTaskDetails(int.Parse(ParentID));
        UpdateUI();
    }
    private async void UpdateUI()
    {
        await InvokeAsync(() => StateHasChanged());
    }
}
